
$(function(){
	$("#files").on("change",function (e) {
        $("#fileList").html("");
        var folders = [];
        /* for (var i = 0; i < arr.length; i++) {
            if (array .indexOf(arr[i]) === -1) {
                array .push(arr[i])
            }
        }*/
        $.each(this.files,function (k,v) {
            //console.log(v.type+"="+v.webkitRelativePath);
        	var filePath = v.webkitRelativePath;
        	var splits = filePath.split("/");
        	var parentFolder = splits[splits.length-2]
        	if (folders.indexOf(parentFolder) === -1) {
        		folders.push(parentFolder);
        		$("#fileList").append( '<div class="item">' +
                        '<span class="info">/' + parentFolder + '</span>' +
                        '</div>' );
            }
        	
        });
        parent.document.getElementById("mainContent").height=document.body.scrollHeight;
    });
	var errorCode =$("#errorCode").val();
	if(errorCode == '1'){
		layer.msg("上传成功");
	}else if(errorCode =='0'){
		layer.msg("上传失败,非预期结果");
	}else if(errorCode == '-1'){
		
		layer.msg("上传失败");
	}
});
function validatation(){ 
	var file = document.getElementById('files'); 
		if(file.value == ""){
			alert("请选择要上传的文件夹！");
			return false;
   	}
   	else{
   		layer.load(1,{offset: '200px'});
   		return true; 
   	} 
}

//form提交
function submitUpload(){
	$("#uploadForm").submit();
}